<div ng-controller="goodsMngCtrl">
    <h1 class="page-header">产品管理</h1>

    <div class="row">
        <div class="col-xs-6 col-sm-3">
            <button type="button" class="btn btn-primary" ui-sref="index.goodsForm">新增</button>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-2">
            <div class="form-group">
                <label>产品名称</label>
                <input class="form-control" ng-model="search.goods_name"/>
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <label>国家</label>
                <select class="form-control" ng-model="search.country" ng-options="country.name as country.name for country in countries">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>

        <div class="col-xs-2">
            <div class="form-group">
                <label>酒庄</label>
                <select class="form-control" ng-model="search.wineryId">
                    <option value="">请选择</option>
                    <option  ng-repeat="item in wineryList" value="{{item.id}}">{{item.name}}</option>
                </select>
            </div>
        </div>

        <div class="col-xs-2">
            <div class="form-group">
                <label>类别1</label>
                <select class="form-control" ng-model="search.cate_id_1">
                    <option value="">请选择</option>
                    <option ng-repeat="item in categoryList | filter:{'parent_id' : 0}" value="{{item.cate_id}}">{{item.cate_name}}</option>
                </select>

            </div>
        </div>

        <div class="col-xs-2">
            <div class="form-group">
                <label>类别2</label>
                <select class="form-control" ng-model="search.cate_id_2">
                    <option ng-repeat="item in categoryList | categoryFilter:search.cate_id_1" value="{{item.cate_id}}">{{item.cate_name}}</option>
                </select>

            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <label>新品推荐</label>
                <input class="checkbox" type="checkbox" ng-model="search.isNew"/>
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <label>限时折扣</label>
                <input class="checkbox" type="checkbox" ng-model="search.sales"/>
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <label>可能感兴趣</label>
                <input class="checkbox" type="checkbox" ng-model="search.recommended"/>
            </div>
        </div>

    </div>
    <div class="row">

        <div class="col-xs-6 col-sm-3">
            <div class="form-group input-group">
                <span class="input-group-btn">
                    <button class="btn btn-primary" type="button" ng-click="getPagedDataAsync();" style="margin-top:24px">
                        搜索
                    </button>
                </span>
            </div>
        </div>
    </div>

    <div class="row">

        <table class="table table-bordered top5">
            <thead>
            <tr>
                <th>商品名称</th>

                <th>价格</th>
                <th width="80px">市场价格</th>
                <th>国家</th>
                <th>等级</th>
                <th width="100px">产区</th>
                <th>酒庄</th>
                <th width="60">单支规格(ml)</th>
                <th>年份</th>
                <th width="100px">成分</th>
                <th width="50px">酒精度(%vol)</th>
                <th>类别1</th>
                <th>类别2</th>
                <th>折扣</th>
                <th>新品</th>
                <th>推荐</th>
                <th>热销</th>
                <th width="150px">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="item in list">
                <td ng-bind="item.goods_name"></td>

                <td ng-bind="item.price.toFixed(2)"></td>
                <td ng-bind="item.market_price.toFixed(2)"></td>
                <td ng-bind="item.country"></td>
                <td ng-bind="item.mgrade_grade"></td>
                <td ng-bind="item.mgrade_areas"></td>
                <td ng-bind="item.wineryName"></td>
                <td ng-bind="item.mgrade_norm"></td>
                <td ng-bind="item.mgrade_year"></td>
                <td ng-bind="item.mgrade_ingredients"></td>
                <td ng-bind="item.mgrade_alcohol"></td>
                <td ng-bind="item.cate_name_1"></td>
                <td ng-bind="item.cate_name_2"></td>
                <td ng-bind="item.sales == 1?'是':'否'"></td>
                <td ng-bind="item.isNew== 1?'是':'否'"></td>
                <td ng-bind="item.recommended== 1?'是':'否'"></td>
                <td ng-bind="item.hot== 1?'是':'否'"></td>
                <td>
                    <a ui-sref="index.goodsForm({id:item.goods_id})" class="btn btn-sm">编辑</a>
                    <a ui-sref="index.inventoryForm({id:item.goods_id,name:item.goods_name})" class="btn btn-sm">库存管理</a>
                    <a data-toggle="modal" data-target="#mySoldOutModal" ng-show="item.closed == 0" ng-click="setGoods(item)" class="btn btn-sm">下架</a>
                    <a ng-show="item.closed == 1" ng-click="setGoods(item);statusChange()" class="btn btn-sm">上架</a>
                    <a ui-sref="index.goodsUpload({id:item.goods_id})" class="btn btn-sm">上传</a>

                </td>
            </tr>
            </tbody>
        </table>

        <pagination boundary-links="true"
                    max-size="5"
                    items-per-page="search.pageSize"
                    total-items="count"
                    ng-model="pageIndex"
                    ng-change="pagedCallback()"></pagination>
    </div>

    <div class="modal fade" id="mySoldOutModal" tabindex="-1" role="dialog"  aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title">
                        下架原因
                    </h4>
                </div>
                <div id="reasonMeg" class="modal-body">
                    <textarea cols="60" rows="4" maxlength="250" id="closeReason" ng-model="goods.close_reason" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal" >取消
                    </button>
                    <button type="button" class="btn btn-primary"
                            data-dismiss="modal" ng-click="statusChange();"  >确定
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>


